<%@page import="hyl.ext.base.MySession"%>
<%@page import="com.servlet.M2"%>
<%@page language="java" contentType="application/json;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page	import="hyl.core.db.*,com.servlet.My,hyl.core.info.Content,hyl.core.MyFun"%>
<%
	MySession tk = My.getSession(request,response);
	int role = tk.getRoleid();
	int index = MyFun.str2int(request.getParameter("rs_index"));
	int size = MyFun.str2int(request.getParameter("rs_size"));
	String oname = request.getParameter("oname");
	String id = request.getParameter("id");
	Content ct = new Content();
	////////////////////////////////dao//////////////////////////////////
	MySqlSelect count = MySqlSelect	.getInstance("SELECT COUNT(1) AS total FROM org a LEFT JOIN USER b ON a.uid=b.id LEFT JOIN org c ON a.i5=c.id WHERE 1=1 ");
	
	String sql = " SELECT b.ualias,a.i0,c.t0,a.dt0,a.dt1,a.dt2,a.t0,a.tm4,a.tm6,a.t1,a.id FROM org a LEFT JOIN USER b ON a.uid=b.id LEFT JOIN org c ON a.i5=c.id WHERE 1=1 {1} ORDER BY a.id DESC {2} ";

	MySqlSelect2 select = MySqlSelect2.getInstance(sql);
	SelectWhere sw = new SelectWhere();
	sw.addLike(" and a.t0 like ?",oname);
	if(MyFun.isEmpty(id)){
		if((role&M2.ROLE_管理员)!=M2.ROLE_管理员){
			sw.add(" and a.uid=?", tk.getUserId());
		}else{
			sw.add(" and a.i0=3");
		}
	}else{
		sw.add(" and a.i5=?", id);
	}
	
	//sw.add(" and ", tk.getUserId());
	count.addParams(sw);
	select.addParams(1, sw);
	select.fromto(2, index, size);
	ct.setCode(1, "查询成功");
	ct.iniBodys(count.getMap());
	ct.addBodyItem("_rs", select.getList2D());
	out.print(ct.toJsonString());
%>